<?php
//has been conveted to a symfony plugin
/**
 * login actions.
 *
 * @package    tinystockmis
 * @subpackage login
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
/*
class loginActions extends sfActions
{
    public function preExecute()
    {
        //fetch the account set
        //$this->acct_sets = Doctrine::getTable("AcctSet")->getAllActiveSets();

    }
    public function executeIndex(sfWebRequest $request)
    {

        #$this->forward('default', 'module');
        //if has signed, forward to the main page
        //if($this->getUser()->isAuthenticated())  {
        //    $this->redirect('/');
        //}
        //$this->forwardIf($this->getUser()->isAuthenticated(), "main", "index");
        $this->redirectIf($this->getUser()->isAuthenticated(), "main/index");
        //show the login form
        $this->login_form = new LoginForm();

    }


    public function executeSignIn(sfWebRequest $request)
    {
        $this->forward404Unless($request->isMethod(sfRequest::POST));

        $this->login_form = new LoginForm();
        
        $this->processForm($request, $this->login_form);
        
        //print_r($this->login_form->getName());
        $this->getUser()->setFlash("errormsg", "您的用户名和密码不正确，请重试.");
        $this->setTemplate("index");
        
    }

    public function executeSignOut(sfWebRequest $request)
    {
        //do sign out process
    }

    protected function processForm(sfWebRequest $request, LoginForm $login_form)
    {
        $login_form->bind( $request->getParameter($login_form->getName()) );
        
        if($login_form->isValid())
        {
            $this->status = "is valid";
            //set the default account set
            $this->getUser()->setAttribute("acct_set", $login_form["acctset"]->getValue());
            //check username and password
            //
            $user = Doctrine::getTable("HrUsers")->findUserByUsername($login_form["username"]->getValue());
            if(is_object($user) and $user->getUserPassword() == sha1($login_form["password"]->getValue())) {
                $this->getUser()->setAttribute("user_id", $user->getId());
                $this->getUser()->setAttribute("user_code", $user->getUserCode());
                $this->getUser()->setAttribute("user_name", $user->getUserName());
                $this->getUser()->setAuthenticated(true);
                //redirect to homepage
                $this->redirect("main/index");
            }
        }

        return false;
        

    }

}
*/